Intent.continueInForeground PRO

Requires Scripting PRO

Intent.continueInForeground is an API that leverages the iOS 26+ AppIntents framework to request the system to bring the Scripting app to the foreground while a Shortcut is running.

This method is used when a script—invoked from Shortcuts—requires full UI interaction within the Scripting app (for example: presenting a form, editing content, picking files, showing a full screen navigation flow, etc.).

When invoked:

  • The system displays a dialog asking the user to continue the workflow in the app.
  • If the user confirms, the system opens Scripting in the foreground and the script continues.
  • If the user cancels, the script terminates immediately.

Because this is a system-level capability of AppIntents:

This API requires iOS 26 or later.


API Definition

1function continueInForeground(
2  dialog?: Dialog | null,
3  options?: {
4    alwaysConfirm?: boolean;
5  }
6): Promise<void>;

Parameters

dialog?: Dialog | null

An optional message explaining why the workflow needs to continue in the foreground.

Dialog supports four formats:

1type Dialog =
2  | string
3  | { full: string; supporting: string }
4  | { full: string; supporting: string; systemImageName: string }
5  | { full: string; systemImageName: string }

Examples:

1"Do you want to continue in the app?"
1{
2  full: "Continue in the Scripting app?",
3  supporting: "The next step requires full UI interaction.",
4  systemImageName: "app"
5}

Passing null will suppress the dialog entirely (not recommended unless you fully understand the UX implications).


options?: { alwaysConfirm?: boolean }

Controls whether the system should always ask for confirmation:

  • alwaysConfirm: false (default) The system may decide whether confirmation is needed based on context.

  • alwaysConfirm: true The system always presents the confirmation dialog.


Execution Behavior

When called inside intent.tsx:

  1. The Shortcut pauses execution.

  2. The system presents a confirmation dialog.

  3. If the user accepts:

    • The Scripting app opens in the foreground.
    • The script continues executing after the await.
  4. If the user cancels:

    • The entire script is terminated immediately.

This mirrors the behavior of Apple’s AppIntents continueInApp() functionality for system apps.


Common Use Cases

Use continueInForeground when the next step cannot run in the background, including:

  • Presenting a full-screen UI (Navigation.present)
  • Editing content in a custom form or navigation stack
  • Selecting files or interacting with UI components
  • Scenarios requiring user input or multi-step flows
  • Showing UI unavailable to background extensions

It should not be used for simple data processing or non-interactive tasks.


Full Code Example

Below is the full working example demonstrating how continueInForeground enables a Shortcut to transfer execution into the Scripting app and then return UI input back to Shortcuts.

1// intent.tsx
2import {
3  Button,
4  Intent,
5  List,
6  Navigation,
7  NavigationStack,
8  Script,
9  Section,
10  TextField,
11  useState
12} from "scripting"
13
14function View() {
15  const dismiss = Navigation.useDismiss()
16  const [text, setText] = useState("")
17
18  return <NavigationStack>
19
20    <List navigationTitle="Intent Demo">
21
22      <TextField
23        title="Enter a text"
24        value={text}
25        onChanged={setText}
26      />
27
28      <Section>
29        <Button
30          title="Return Text"
31          action={() => {
32            dismiss(text)
33          }}
34          disabled={!/\S+/.test(text)}
35        />
36      </Section>
37
38    </List>
39
40  </NavigationStack>
41}
42
43async function runIntent() {
44
45  // Step 1: Ask the user to continue in the foreground app
46  await Intent.continueInForeground(
47    "Do you want to open the app and continue?"
48  )
49
50  // Step 2: Present UI inside the Scripting app
51  const text = await Navigation.present<string | null>(
52    <View />
53  )
54
55  // Step 3: Optionally go back to Shortcuts
56  Safari.openURL("shortcuts://")
57
58  // Step 4: Return the result to Shortcuts
59  Script.exit(
60    Intent.text(
61      text ?? "No text return"
62    )
63  )
64}
65
66runIntent()

Notes and Recommendations

  1. Requires iOS 26+ Do not call this API on older systems.

  2. Use dialogs to explain why foreground interaction is required This improves user trust and Shortcuts clarity.

  3. Always handle the cancellation case If the user cancels, your script stops. Avoid assuming foreground UI will always appear.

  4. Foreground UI must be meaningful Only use this API when the upcoming step truly requires UI.

  5. Can be combined with SnippetIntent (iOS 26+) For workflows that mix in-Shortcut Snippet UI with in-app full UI.


Summary

Intent.continueInForeground enables scripts invoked from Shortcuts to request foreground execution when UI interaction is required. It is:

  • Based on iOS 26 AppIntents capabilities
  • A system-confirmed context switch
  • Essential for workflows involving full UI interactions
  • Safely integrated via a structured Dialog system

This method allows Scripting to support advanced automation flows that seamlessly transition between Shortcuts and the full Scripting app UI.